package com.bgIntlgn.client.entity.privilege;

import yuhuibear.poat.annotations.relation.View;
import yuhuibear.poat.object.bean.Bean;

@View(name = "account_details", sqlToCreate = "select a.*, e.name as owner, e.department as department_id, e.work_number as work_number"
		+ " from accounts as a, employees as e where a.employee_id = e.id;")
public class AccountDetail implements Bean {

	private String owner;

	private String work_number;

	private Long departmentId;

	private Long id;

	private String role;

	private Long employeeId;

	private String name;

	private String password;

	private Integer logCnt = new Integer(0);

	private boolean enable;

	public Account toAccount() {
		Account a = new Account();
		a.setId(id);
		a.setName(name);
		a.setEmployeeId(employeeId);
		a.setRole(role);
		a.setLogCnt(logCnt);
		a.setPassword(password);
		a.setEnable(enable);
		return a;
	}

	public AccountDetail() {
	}

	public AccountDetail(Account acnt) {
		if (acnt == null)
			return;
		id = acnt.getId();
		role = acnt.getRole();
		name = acnt.getName();
		password = acnt.getPassword();
		logCnt = acnt.getLogCnt();
		employeeId = acnt.getEmployeeId();
		enable = acnt.isEnable();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	public Long getEmployeeId() {
		return employeeId;
	}

	public void setEmployeeId(Long employeeId) {
		this.employeeId = employeeId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Integer getLogCnt() {
		return logCnt;
	}

	public void setLogCnt(Integer logCnt) {
		this.logCnt = logCnt;
	}

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public String getOwner() {
		if (owner != null)
			owner = owner.trim();
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public Long getDepartmentId() {
		return departmentId;
	}

	public void setDepartmentId(Long departmentId) {
		this.departmentId = departmentId;
	}

	public String getWork_number() {
		return work_number;
	}

	public void setWork_number(String work_number) {
		this.work_number = work_number;
	}

}
